@echo off
:: 检查是否以管理员身份运行，如果不是，则重新以管理员身份启动
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
    echo Request administrator privileges...
    goto UACPrompt
) else (
    goto AdminApproved
)

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
    echo WScript.Quit >> "%temp%\getadmin.vbs"
    cscript //nologo "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:AdminApproved
`cd /d "D:\work\xh\cloud-farm\ruoyi-ui"
echo Entering directory: D:\work\xh\cloud-farm\ruoyi-ui
echo Execute npm run dev...
npm run dev

:: 保持窗口打开，查看输出结果（可选）
echo.
echo The development server has started. Press any key to exit...
pause >nul
exit